import os
from dotenv import load_dotenv
import secrets

load_dotenv()

class Settings:
    # 数据库配置
    DATABASE_URL: str = os.getenv(
        "DATABASE_URL", 
        "mysql+asyncmy://root:20234108%40123@localhost:3306/DetectionChat?charset=utf8mb4"
    )
    
    # JWT配置
    # 生成一个随机的密钥作为默认值，但建议在生产环境中设置环境变量
    SECRET_KEY: str = os.getenv("SECRET_KEY", secrets.token_urlsafe(32))
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "30"))
    
    # 密码加密配置
    PASSWORD_SALT: str = os.getenv("PASSWORD_SALT", secrets.token_hex(16))

settings = Settings() 
